<?php


class Server
{
    const PORT = 6061;
    public function port()
    {
        $shell = "netstat -anp | grep ".self::PORT . " |grep LISTEN | wc -l ";
    ;
        $result = shell_exec($shell);
        if($result !=1){
            //发送报警服务 短信 邮件
            echo date("Y-m-d H:i:s").'error'.PHP_EOL;
        }else{
            echo date("Y-m-d H:i:s").'success'.PHP_EOL;
        }
//        echo $res;
    }
}
//nohup
// nohup php Server.php > /wwwdata/swoole/tp5/server/a.txt &

swoole_timer_tick(2000,function ($timer_id){
    (new Server())->port();
    echo "time_start".PHP_EOL;
});
